package com.cos.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;


import com.cos.entity.GoodsEntity;
import com.cos.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;





/**
 * 
 *
 * @author lyc
 * @email 2102@qq.com
 * @date 2021-07-08 15:45:07
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {
    @Autowired
    private GoodsService goodsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public List<GoodsEntity> list(){
        List<GoodsEntity> list = goodsService.list();
        return list;
    }


    /**
     * 信息
     */
    @RequestMapping("/info")
    public GoodsEntity info(@RequestBody Integer id){
		GoodsEntity goods = goodsService.getById(id);
        return goods;
    }

    /**
     * 保存
     */
    @RequestMapping("/save")

    public boolean save(@RequestBody GoodsEntity goods){
		goodsService.save(goods);

        return goodsService.save(goods);
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public boolean update(@RequestBody GoodsEntity goods){
		goodsService.updateById(goods);

        return goodsService.updateById(goods);
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")

    public boolean delete(@RequestBody Integer[] ids){
		goodsService.removeByIds(Arrays.asList(ids));

        return goodsService.removeByIds(Arrays.asList(ids));
    }

}
